const moment = require('moment');
module.exports = {
    devServer:{
        proxy:{
            '^/api':{
                target:'http://127.0.0.1:7002',
                pathRewrite:{
                    '^/api':''
                }
            }
        },
        before(app){
            app.get('/api/echartsData',(req,res) => {
                let curTime = new Date().getTime();  //当前的时间戳
                let day = 7;
                let time = 86400000; //一天的时间戳
                let data = [];  //[{},{},{time,num}]
                for(let i = 1;i <= day;i++){
                    let timer = curTime - time*i;
                    data.push({
                        time:moment(timer).format('YYYY-MM-DD'),
                        num:Math.ceil(Math.random()*100)
                    })
                }

                res.send({
                    code:1,
                    data,
                    msg:'success'
                })
            })
        }
    }
}